<template>
  <view>
    <uni-card class="card1" shadow="15px 15px 30px #bebebe,-15px -15px 30px #ffffff;"
      thumbnail="https://tjwmy.com/W%5B%29J%24EB%25~P7R8%25%29Y26F5DCK.bmp">
      <template v-slot:title>
        <uni-list>
          <uni-list-item title="今日计划" note="长按删除/点击修改" thumb="https://tjwmy.com/1.png" rightText="添加" showArrow
            :to="`/subpkg/schedule_add/schedule_add`" @click="onClick" />
        </uni-list>
      </template>
      <view class="top">
        {{weather}}
      </view>
      <view class="body">
        <unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" collection="schedule">
          <view v-if="error">{{error.message}}</view>
          <view v-else>

            <view class="schedule" v-for="item in data" :key="item._id">
              <view class="schedule_item" @longpress.native="rmItem(item._id)" @click.native="changeItem(item)">
                <uni-icons type="circle"></uni-icons>
                {{item.content}}
                <text>{{item.time}}</text>
              </view>
            </view>
          </view>
        </unicloud-db>
      </view>
    </uni-card>
  </view>
</template>

<script>
  export default {
    name: "my-card1",
    data() {
      return {
        weather: '晴 周二 8, 21:08 下午',
      };
    },
    methods: {
      onClick() {},

      rmItem(id) {
        this.$refs.udb.remove(id)
      },
      changeItem(item) {
        uni.navigateTo({
          url: '/subpkg/changeItem/changeItem?item=' + JSON.stringify(item),
          success: res => {},
          fail: () => {},
          complete: () => {}
        });
      }
    }
  }
</script>

<style lang="scss">
  .card1 {
    width: 190px;
    height: 254px;
  }
</style>
